package com.woniuxy.yuekeuser.dao;

import com.woniuxy.yuekeuser.model.CampsiteFood;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniuxy.yuekeuser.model.CampsiteFoodPicture;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Freedom
 * @since 2020-11-03
 */
public interface CampsiteFoodMapper extends BaseMapper<CampsiteFood> {
    /**
     * 营地美食表添加数据
     *
     */
    @Insert("insert into campsite_food (campsite_food_name,campsite_id,campsite_food_words) values(#{campsiteFoodName},#{campsiteId},#{campsiteFoodWords})")
    @Options(useGeneratedKeys = true,keyProperty = "campsiteFoodId")
    public void addcampsiteFood(CampsiteFood campsiteFood);

    /**
     * 营地美食图片表添加数据
     */
    @Insert("insert into campsite_food_picture (campsite_food_picture_address,campsite_food_id) values(#{campsiteFoodPictureAddress},#{campsiteFoodId})")
    public void addCampsiteFoodImage(CampsiteFoodPicture campsiteFoodPicture);
    /**
     * 根据美食名查询美食id
     */
    @Select("select campsite_food_id from campsite_food where campsite_food_name = #{campsiteFoodName}")
    public int findCampsiteFoodIdByFoodName(String foodName);

    /**
     * 动态查询营地美食数据
     *
     */
    public List<CampsiteFood> findFoods(String campsiteName,int index,int pageSize);

    /**
     * 动态查询营地美食条数
     *
     */
    public int findFoodCount(String campsiteName);

    /**
     * 根据美食id查询美食的图片
     */
    @Select("select campsite_food_picture_address,campsite_food_picture_words,campsite_food_id,campsite_food_picture_id from campsite_food where campsite_food_id =#{id} ")
    public List<CampsiteFoodPicture> findFoodImagesByFoodId(int id);


    /**
     * 根据美食id查询 美食的第一张图片
     */
    @Select("select campsite_food_picture_address from campsite_food_picture where campsite_food_id =#{id} limit 0,1 ")
    public String findFoodImageByFoodId(int id);
}
